﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LDSP.BRL;
using System.Data;
using System.IO;

namespace LDSP.UI.EnterpriseCommonUser
{
    public partial class MyPage : BRL.BaseEnterpriseCommonUserPage
    {
        public string Newest { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadLogo();
            Newest = GetNewest();
        }

        private void LoadLogo()
        {
            try
            {
                string logPath = "~/LogoFiles/" + this.LoginUser.EnterpriseID + ".gif";
                if (!File.Exists(Server.MapPath(logPath)))
                {
                    logPath = "~/LogoFiles/default.gif";
                }

                this.Image1.ImageUrl = logPath;
            }
            catch
            {
            }
        }

        private string GetNewest()
        {
            string newest = string.Empty;
            int days = Int32.Parse(SystemConfig.AddNewAlertDays);
            DataTable newsestList = new Codification().GetRecordsUploadDate(DateTime.Now.AddDays(days * -1));
            foreach (DataRow row in newsestList.Rows)
            {
                newest += "<<" + row["name"].ToString() + ">>,";
            }

            if (newest.Length > 0)
            {
                newest = newest.Remove(newest.Length - 1, 1);
            }

            return newest;
        }
    }
}